﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App;
using Infrastructure;
using OpenAuth.Repository.Domain;

namespace OpenAuth.WebApi.Areas.HisApi.Controllers
{
    /// <summary>
    /// 门诊当班挂号
    /// </summary>
    [Route("HisApi/[controller]/[action]")]
    [ApiController]
    public class OndutyController : ControllerBase
    {
        /// <summary>
        /// 全院当天号源查询
        /// </summary>
        private readonly CDRGH008App cdrgh008App;
        /// <summary>
        /// 当班出诊科室查询
        /// </summary>
        private readonly CDRGH001App cdrgh001App;
        /// <summary>
        /// 当班出诊医生查询
        /// </summary>
        private readonly CDRGH004App cdrgh004App;
        /// <summary>
        /// 当班科室信息查询
        /// </summary>
        private readonly CDRGH002App cdrgh002App;
        /// <summary>
        /// 当班科室号源信息查询
        /// </summary>
        private readonly CDRGH003App cdrgh003App;
        /// <summary>
        /// 当班医生查询(当班医生信息查询)
        /// </summary>
        private readonly CDRGH005App cdrgh005App;
        /// <summary>
        /// 当班医生号源信息查询
        /// </summary>
        private readonly CDRGH006App cdrgh006App;
        /// <summary>
        /// 当日挂号信息查询（查询门诊患者挂号记录）
        /// </summary>
        private readonly CDRGH007App cdrgh007App;
        public OndutyController(CDRGH008App _cdrgh008App, CDRGH001App _cdrgh001App, CDRGH004App _cdrgh004App, CDRGH002App _cdrgh002App, CDRGH003App _cdrgh003App, CDRGH005App _cdrgh005App, CDRGH006App _cdrgh006App, CDRGH007App _cdrgh007App)
        {
            cdrgh008App = _cdrgh008App;
            cdrgh001App = _cdrgh001App;
            cdrgh004App = _cdrgh004App;
            cdrgh002App = _cdrgh002App;
            cdrgh003App = _cdrgh003App;
            cdrgh005App = _cdrgh005App;
            cdrgh006App = _cdrgh006App;
            cdrgh007App = _cdrgh007App;

        }
        /// <summary>
        /// 全院当天号源查询///测试没问题///卫宁文档无示例
        /// </summary>
        [HttpGet]
        public Response QueryCDRGH008By()
        {
            //准备返回对象
            var result = new Response<List<CDRGH008>>();
            var queryResult = cdrgh008App.QueryCDRGH008By();
            result.Result = queryResult.ToList();
            return result;
        }
        /// <summary>
        /// 当班出诊科室查询///测试没问题
        /// </summary>
        [HttpGet]
        public Response QueryCDRGH001ByYydm()
        {
            //准备返回对象
            var result = new Response<List<CDRGH001>>();
            var queryResult = cdrgh001App.QueryCDRGH001ByYydm();
            result.Result = queryResult.ToList();
            return result;
        }
        /// <summary>
        /// 当班出诊医生查询///测试没问题
        /// </summary>
        /// <param name="ksdm">科室代码</param>
        /// <returns></returns>
        [HttpGet]
        public Response QueryCDRGH004ByKsdm(string ksdm)
        {
            //准备返回对象
            var result = new Response<List<CDRGH004>>();
            var queryResult = cdrgh004App.QueryCDRGH004ByKsdm(ksdm);
            result.Result = queryResult.ToList();
            return result;
            
        }
        /// <summary>
        /// 当班科室信息查询///测试没问题
        /// </summary>
        [HttpGet]
        public Response QueryCDRGH002By()
        {
            //准备返回对象
            var result = new Response<List<CDRGH002>>();
            var queryResult = cdrgh002App.QueryCDRGH002By();
            result.Result = queryResult.ToList();
            return result;
        }
        /// <summary>
        /// 当班科室号源信息查询///测试没问题
        /// </summary>
        /// <param name="ksdm">科室代码</param>
        /// <param name="dqsjbz">到期时间标志</param>
        /// <returns></returns>
        [HttpGet]
        public Response QueryCDRGH003ByKsdm(string ksdm, string dqsjbz)
        {
            //准备返回对象
            var result = new Response<List<CDRGH003>>();
            var queryResult = cdrgh003App.QueryCDRGH003ByKsdm(ksdm, dqsjbz);
            result.Result = queryResult.ToList();
            return result;
        }
        /// <summary>
        /// 当班医生查询(当班医生信息查询)///测试没问题
        /// </summary>
        /// <param name="ksdm">科室代码</param>
        /// <returns></returns>
        [HttpGet]
        public Response QueryCDRGH005ByKsdm(string ksdm)
        {
            //准备返回对象
            var result = new Response<List<CDRGH005>>();
            var queryResult = cdrgh005App.QueryCDRGH005ByKsdm(ksdm);
            result.Result = queryResult.ToList();
            return result;
        }
        /// <summary>
        /// 当班医生号源信息查询 （存储有问题）///没测出来
        /// </summary>
        /// <param name="ysdm">医生代码</param>
        /// <returns></returns>
        [HttpGet]
        public Response QueryCDRGH006ByYsdm(string ysdm)
        {
            //准备返回对象
            var result = new Response<List<CDRGH006>>();
            var queryResult = cdrgh006App.QueryCDRGH006ByYsdm(ysdm);
            result.Result = queryResult.ToList();
            return result;
        }
        /// <summary>
        /// 当日挂号信息查询（查询门诊患者挂号记录）///测试没问题
        /// </summary>
        /// <param name="patid">患者唯一编码</param>
        /// <param name="ksrq">开始日期</param>
        /// <param name="jsrq">结束日期</param>
        /// <param name="hzxm">患者姓名</param>
        /// <param name="czybz">操作员标志</param>
        /// <param name="ghxh">医生代码</param>
        /// <returns></returns>
        [HttpGet]
        public Response QueryCDRGH007ByPatid(string patid, string ksrq, string jsrq, string hzxm, string czybz, string ghxh)
        {
            //准备返回对象
            var result = new Response<List<CDRGH007>>();
            var queryResult = cdrgh007App.QueryCDRGH007ByPatid(patid,ksrq,jsrq,hzxm,czybz,ghxh);
            result.Result = queryResult.ToList();
            return result;
        }
    }
}